home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / megascroller / megascroller.dba < prev    next >
Encoding:
Text File  |  2000-07-05  |  3.8 KB  |  189 lines

  1. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. `            MegaScroller !
  3. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  4. ` By Rich Davey (rich@fatal-design.com)
  5. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  6. ` Music listened  to while  coding this
  7. ` Headrush CD 1 (HyperLogic Trance Mix)
  8. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9.  
  10. sync rate 0
  11. sync on
  12. hide mouse
  13.  
  14. `    os is the % the font will be increased by.
  15. `    Valid values are 2,4,5 and 10. Others will result in missing characters
  16. `    2 is nice to read, 10 is massive! at least half a screen high.
  17. `    s = the speed of the scroller. 16 is very fast, 8 is nice, 4 smooth.
  18.  
  19. os=2 : s=12
  20.  
  21. `    Load up a font: ox and oy are the dimensions (pixel) of the font set
  22. `    Uncomment out a pair to see a new font in action!
  23.  
  24. load bitmap "knight6.bmp",1
  25. ox=32 : oy=25
  26.  
  27. `load bitmap "fresh.bmp",1
  28. `ox=32 : oy=25
  29.  
  30. `load bitmap "geo_font.bmp",1
  31. `ox=32 : oy=30
  32.  
  33. `load bitmap "dr_satan.bmp",1
  34. `ox=32 : oy=33
  35.  
  36. `load bitmap "knight3.bmp",1
  37. `ox=32 : oy=32
  38.  
  39. `    ----------------------------------------------------------------------
  40. `    This is where the fun starts... (see end for scroll text itself)
  41. `    ----------------------------------------------------------------------
  42.  
  43. x=0 : y=0 : bw#=ox*os
  44.  
  45. `    rip the font from the BMP into seperate images
  46.  
  47. for i=1 to 60
  48.  
  49.     get image i,x,y,x+ox,y+oy
  50.     inc x,ox
  51.  
  52.     if x>=319
  53.         x=0
  54.         inc y,oy
  55.     endif
  56.  
  57.     sync
  58.  
  59. next i
  60.  
  61. i=1
  62.  
  63. `    create a new working environment
  64.  
  65. create bitmap 2,640,480
  66.  
  67. `    this scales and pastes the font to make the enlarged version
  68.  
  69. if os>1
  70.  
  71.     for z=61 to 120
  72.     
  73.         create bitmap 1,ox*os,oy*os
  74.         paste image i,0,0
  75.         set current bitmap 2
  76.         copy bitmap 1,0,0,ox,oy,2,0,0,ox*os+os,oy*os
  77.         get image z,0,0,ox*os+os,oy*os
  78.         inc i
  79.     
  80.     next z
  81.  
  82. else
  83.  
  84.     print "Cannot have OS size less than 2"
  85.     end
  86.  
  87. endif
  88.  
  89. set current bitmap 0
  90. delete bitmap 2
  91.  
  92. bc=640/bw#+1
  93.  
  94. `    pad out the initial text for a screens width
  95.  
  96. for a=1 to bc
  97.  
  98.     st$=st$+" "
  99.  
  100. next a
  101.  
  102. `    read in the text data and check the length
  103.  
  104. read s$
  105. st$=st$+s$
  106. lot=len(st$)+1
  107. if lot<12 then st$=st$+"           "
  108.  
  109. dim x#(bc)
  110. dim t$(bc)
  111.  
  112. `    we're using 2 arrays to keep track of things. One (x) holds the x
  113. `    coords of the sprites as they move. The other the current letter of
  114. `    that sprite.
  115.  
  116. for a=1 to bc
  117.  
  118.     x#(a)=bw#*a
  119.     t$(a)=mid$(st$,a)
  120.     as=asc(t$(a))
  121.     sprite a,x#(a),0,29+as
  122.     set sprite a,0,1
  123.  
  124. next a
  125.  
  126. `    just a bit of math to centre the font on-screen based on its height
  127.  
  128. y=(480-oy*os)/2 : t=bc
  129.  
  130. do
  131.  
  132.     cls 0
  133.  
  134. `    this moves each sprite left, checks to see if its off the screen and
  135. `    then assigns it the next letter from the scroll text if it is
  136.  
  137.     for a=1 to bc
  138.  
  139.         x#=x#(a)
  140.  
  141.         dec x#,s
  142.  
  143.         if x#=<-0-bw#
  144.             x#(a)=640
  145.             inc t
  146.  
  147.             if t=lot
  148.                 t=1
  149.                 read st$
  150.                 if st$="*"
  151.                     restore
  152.                     read st$
  153.                 endif
  154.                 lot=len(st$)+1
  155.             endif
  156.  
  157.             t$(a)=mid$(st$,t)
  158.         else
  159.             x#(a)=x#
  160.         endif
  161.  
  162.         as=asc(t$(a))
  163.         sprite a,x#(a),y,29+as
  164.  
  165.     next a
  166.  
  167.     sync
  168.  
  169. loop
  170.  
  171. `    and here is the actual text itself...
  172. `    placed into a data set because you will overflow a string buffer
  173. `    after only 3 lines of normal text otherwise! which would make for a
  174. `    rather dull and short scrolly :-)
  175.  
  176. `    we use a single * as the end of text delimeter - don't forget it!
  177.  
  178. data "DARKFORGE IS PROUD TO RELEASE IT'S MEGASCROLLER CODE! ... "
  179. data "CODED IN JULY 2000 FOR THE DARKBASIC MASSES. THIS CODE IS "
  180. data "UNIQUE IN THAT IT DOESN'T USE MASSIVE BITMAPS OR 3D ! "
  181. data "PUBLIC DOMAIN AS ALWAYS... AND NOW, WHAT SCROLLER WOULD BE "
  182. data "COMPLETE WITHOUT SOME GREETINGS??! ... "
  183. data "KUDOS FLY OUT TO.. TRACER! (THE SMOKING DRINKING CODING MASTER), "
  184. data "LEE (MAY WE BOW TO YOU!), PJAY, SI, WARPY, CHRIS AND THE REST OF "
  185. data "THE MOB ON IRC.CJB.NET !  THIS IS RICH DOING THAT WRAP THING "
  186. data "..........   "
  187. data "*"
  188.  
  189.